﻿@model BrnShop.Web.Admin.Models.FriendLinkModel

@section header{
    <title>添加友情链接</title>
    <link type="text/css" rel="stylesheet" href="/administration/css/site.css"/>
    <script type="text/javascript" src="/administration/scripts/jquery.js"></script>
    <link type="text/css" rel="stylesheet" href="/components/webuploader/webuploader.css" />
    <script type="text/javascript" src="/components/webuploader/webuploader.js"></script>
    <script type="text/javascript" src="/administration/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/administration/scripts/jquery.validate.unobtrusive.js"></script>
     <script type="text/javascript">
         $(function () {
             var uploader = WebUploader.create({
                 pick: '.uploadBut',
                 auto: true,
                 swf: '/components/webuploader/Uploader.swf',
                 server: '/admin/tool/upload?operation=uploadfriendlinklogo',
                 fileVal: 'upload',
                 accept: {
                     title: 'Images',
                     extensions: '@ViewData["allowImgType"]',
                     mimeTypes: 'image/*'
                 },
                 fileSingleSizeLimit: @ViewData["maxImgSize"]
             });

             uploader.on('uploadProgress', function(file, percentage) {
                 $(".uploadPreview").html("上传中...");
             });

             uploader.on('uploadSuccess', function(file, response) {
                 var data = response._raw;
                 if (data == "-1")
                     $(".uploadPreview").html('图片不能为空');
                 else if (data == "-2")
                     $(".uploadPreview").html('图片类型不允许');
                 else if (data == "-3")
                     $(".uploadPreview").html('图片太大');
                 else {
                     $(".uploadPreview").html("<img src=\"@WorkContext.ImageCDN/upload/friendlink/" + data + "\"  />");
                     $("#FriendLinkLogo").val(data);
                 }
             });

             uploader.on('uploadError', function(file) {
                 $(".uploadPreview").html("上传失败");
             });
         });
    </script>
}

@section body{
<h1 class="rightH1">
友情链接管理 &gt;&gt; 添加友情链接
<div class="right">
<a href="@Html.Raw(ViewData["referer"].ToString())" class="menuBT"><img src="/administration/images/goback.jpg"/>返回列表</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</h1>

@using (Html.BeginForm())
{
<div class="addTable">
<table width="100%">
  <tr>
    <td width="80px" align="right">链接名称：</td>
    <td>@Html.TextBoxFor(x => x.FriendLinkName, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.FriendLinkName)</td>
    </tr>
          <tr>
    <td align="right">链接提示：</td>
    <td>@Html.TextBoxFor(x => x.FriendLinkTitle, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.FriendLinkTitle)</td>
    </tr>
          <tr>
    <td align="right">链接地址：</td>
    <td>@Html.TextBoxFor(x => x.FriendLinkUrl, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.FriendLinkUrl)</td>
    </tr>
        <tr>
    <td align="right">Logo地址：</td>
    <td>
        <div class="upload">
            <div class="uploadPreview">
                @if (!string.IsNullOrEmpty(Model.FriendLinkLogo))
                {
                    <img src="@WorkContext.ImageCDN/upload/friendlink/@Model.FriendLinkLogo" />
                }
                else
                {
                    @:暂无图片
                }
            </div>
            <div class="left">
                <div class="uploadProgressBar"></div>
                <div class="uploadBut">选择图片</div>
            </div>
            <div class="clear"></div>
        </div>
        @Html.TextBoxFor(x => x.FriendLinkLogo, new { @class = "hide" })
        @Html.ValidationMessageFor(x => x.FriendLinkLogo)
    </td>
    </tr>
                <tr>
                    <td align="right">
                        打开目标：
                    </td>
                    <td>
                        <p>
                            <label>@Html.RadioButtonFor(x => x.Target, 0, new { @class = "checkbox" })本窗口</label>
                            <label>@Html.RadioButtonFor(x => x.Target, 1, new { @class = "checkbox" })新窗口</label>
                            <br />
                        </p>
                    </td>
                </tr>

      <tr>
    <td align="right">排序：</td>
    <td>@Html.TextBoxFor(x => x.DisplayOrder, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.DisplayOrder)</td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>
    <a href="" class="addBt" id="sumbitBut" ><img src="/administration/images/submit.jpg" /></a>
            <script type="text/javascript">
                $(function () {
                    $("#sumbitBut").click(function () {
                        $("form:first").submit();
                        return false;
                    })
                });
        </script>
    </td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
}
}